package com.viphuli.app.tool.handler;

import java.util.List;

import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

import com.offroader.utils.ViewUtils;
import com.viphuli.app.tool.adapter.ArrangeActionTypeAdapter;
import com.viphuli.app.tool.bean.page.ArrangeTypeListPage;
import com.viphuli.app.tool.bean.part.ArrangeType;
import com.viphuli.app.tool.fragment.ArrangeActionTypeFragment;

public class ArrangeActionTypeResponseHandler extends MyBaseHttpResponseHandler<ArrangeActionTypeFragment, ArrangeTypeListPage> implements
		OnItemClickListener {

	@Override
	public void deal() {

		List<ArrangeType> arrangeTypeList = page.getArrangeTypeList();
		caller.getList().addAll(arrangeTypeList);
		ArrangeActionTypeAdapter adapter = new ArrangeActionTypeAdapter(caller.getList());
		caller.setAdapter(adapter);
		caller.getListview().setAdapter(adapter);
		caller.getListview().setOnItemClickListener(this);

	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

		//选择操作
		ArrangeActionTypeAdapter adapter = (ArrangeActionTypeAdapter) caller.getAdapter();

		List<Integer> checkList = adapter.getCheck();
		if (checkList != null && checkList.size() >= 2) {
			ViewUtils.toast("每天最多两个排班");
		}else{
			adapter.check(position);
		}

		

	}
}
